<template>
  <div class="nav-bg" :class="{navScroll: scrollDirection}"></div>

  <theme-nav class="theme-nav transDot3" :class="{navScroll: scrollDirection}"></theme-nav>

  <div class="content-wrapper">
    <router-view class="content-main"></router-view>

    <div class="help-card transDot3" :class="{navScroll: scrollDirection}">
      <ad-one class="ad-one"></ad-one>
      <ad-two class="ad-two"></ad-two>
      <authority-card class="authority"></authority-card>
    </div>
  </div>
</template>

<script>
import throttle from 'lodash/throttle'

import ThemeNav from '@/components/ThemeNav.vue'

import AuthorityCard from '@/components/HelpCard/AuthorityCard.vue'
import AdOne from '@/components/HelpCard/AdOne.vue'
import AdTwo from '@/components/HelpCard/AdTwo.vue'

export default {
  components: {
    ThemeNav,
    AuthorityCard,
    AdOne,
    AdTwo
  },
  data() {
    return {
      scrollDirection: false,

    }
  },
  mounted() {
    let beforeY = 0;
    document.addEventListener('scroll', throttle(() => {
      if(window.scrollY - beforeY > 0) {
        this.scrollDirection = true;
      } else {
        this.scrollDirection = false;
      }
      beforeY = window.scrollY
    }, 200));
  }
}
</script>

<style scoped lang="less">
@w: var(--innerWidth);
@w1: var(--innerWidthPart1);
@w2: var(--innerWidthPart2);

.nav-bg {
  position: fixed;
  z-index: 8888;
  top: 0;
  width: 100vw;
  height: 130px;
  background-color: var(--bgColor);
  transition: .3s;
}

.theme-nav {
  --themeNavHeight: 60px;
  --themeNavWidth: @w;
  z-index: 8888;
  position: fixed;
  top: calc(var(--topNavHeight) + 10px);
  left: 0;
  right: 0;
  margin: 0 auto;
}

.content-wrapper {
  margin: 140px auto;
  display: flex;
  justify-content: space-between;
  width: @w;

  .help-card {
    position: fixed;
    right: calc((100% - var(--innerWidth)) / 2);
    width: var(--innerWidthPart2);

    .ad-one {
      --adOneWidth: var(--innerWidthPart2);
    }

    .ad-two {
      --adTwoWidth: var(--innerWidthPart2);
    }

    .authority {
      --authorityCardWidth: var(--innerWidthPart2);
    }
  }
}
</style>